/**
 * Created by dev-001 on 2017/3/23.
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const StudentSchema = new Schema({
    name: String,
    phone: String, //电话
    avatar: String, //头像
    idCard: String, //id编号
    status: Number, //状态
    sid: String,//学生考号
    school: {
        type: ObjectId,
        ref: 'School'
    },
    clazz: {
        type: ObjectId,
        ref: 'Clazz'
    },
    createdAt: Date,
    updatedAt: Date
});

StudentSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Student', StudentSchema);